package com.ruoyi.individual.enumeration;

/**
 * <p>Title: TypeEnum</p>
 * <p>name: </p>
 * <p>Copyright: Copyright (c) 2023</p>
 * <p>author: YaoHui</p>
 * <p>version: 1.0</p>
 */
public enum TypeEnum {
    NOVEL("0", "小说"),
    BIOGRAPHY("1", "传记"),
    SCIENCE_FICTION("2", "科幻"),
    HISTORY("3", "历史"),
    ART("4", "艺术"),
    TEXTBOOK("5", "教科书"),
    REFERENCE("6", "参考书");

    private final String code;

    private final String name;

    TypeEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    // 提供一个静态方法来根据代码获取对应的枚举状态
    public static TypeEnum getStateByCode(String code) {
        for (TypeEnum state : TypeEnum.values()) {
            if (state.code.equals(code)) {
                return state;
            }
        }
        return null;
    }
    public static String getStateNameByCode(String code) {
        for (TypeEnum state : TypeEnum.values()) {
            if (state.code.equals(code)) {
                return state.getName();
            }
        }
        return null;
    }
}
